<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ taglib uri="/struts-tags" 	prefix="s"%>
<%@ include file="/jsp/common/common_head.jsp" %>
<!DOCTYPE HTML>
<html>
<head>
<%@ include file="/jsp/common/common_script.jsp"%>
<title>鹿图旅游语音播报平台</title>
<link type="text/css" rel="stylesheet" href="${ctx}/css/login/login.css"/>
</head>

<body>
<div class="centerDiv">
<div class="login_bg">
        <div class="login">
			<div id="loginRslt" class="msg msg-info" style="display:none;"></div>
			<div class="other"></div>	
			<s:form action="/webcom/UserLogin.action" method="post">
			<s:actionerror/>
			<table width="100%" cellspacing="0">
			<tbody>
				<tr>
					<th width="64" align="right" style="font-size: 12px;">账户</th>
					<td colspan="3" ><s:textfield id="username" name="username" size="20" cssClass="easyui-validatebox txt"  data-options="required:true" onKeyDown="doLogin(event)"/></td>
				</tr>
				<tr>
					<th align="right" style="font-size: 12px;">密码</th>
					<td colspan="3" ><s:password name="password" cssClass="inputText easyui-validatebox txt pwd" data-options="required:true" onKeyDown="doLogin(event)"/></td>
					
				</tr>
<!-- 				<tr>
					<th align="right" style="font-size: 12px;">验证码</th>
					<td  style="width: 70px;">
						<input type="text" id="keyword" name="keyword"  style="width:60px;"  class="txt" data-options="required:true" onKeyDown="doLogin(event)"/>
					</td>
					<td width="58">
						<img id="imgCode" src="system/login_keyword.do" onclick="refresh();" />
					</td>
					<td width="100">
					   <a href="#" onclick="refresh();"  style="font-size: 12px;">刷新</a>
					</td>
				</tr> -->
				<tr>
				    <th></th>
					<td colspan="3" class="altbox" style="padding: 3px 5px;">
						<s:submit cssClass="button" value="登 录" name="btnLogin"/>
					</td>
				</tr>

				</tbody>
			  </table>
			  
			  
			  <tr>
				    <th></th>
					<td colspan="3" class="altbox" style="padding: 3px 5px;">
						<input type="button" id="btnTest" value="TEST" class="button1" style="width:50px;"/>
					</td>
			</tr>
			  <table id="testGrid"></table>
			</s:form>
			
<form method="post" action="http://upload.qiniu.com/" enctype="multipart/form-data">
  <input name="key" type="hidden" value="<resource_key>">
  <input name="x:<custom_name>" type="hidden" value="<custom_value>">
  <input name="token" type="hidden" value="<upload_token>">
  <input name="file" type="file" />
  <input name="crc32" type="hidden" />
  <input name="accept" type="hidden" />
</form>
			
    </div>
    <div class="clear"></div>
  </div>
</div>
<div class="hiddenDiv"></div>
<input type="text" style="display: none;" value=<%=request.getParameter("requestURI")%> id="requestURI">
<script>
$(function() {
	
	var param = {};
    param.user_id = '1';
 	$("#testGrid").datagrid({
 		url:null,//appPath+'/itbImg/getImageList.action',
 		height:'full',
 		striped: true,
 		fitColumns:true,
 		//queryParams: param,
 		singleSelect:false,
 		checkbox:false,
 		columns:[[
 		      {field:'user_id',title:'用户ID',width:40,align:'left',sortable:true},
 		      {field:'tmpl_id',title:'模板ID',width:40,align:'left',sortable:true},
 		      {field:'page_num',title:'页号',width:40,align:'left',sortable:true},
 		      {field:'url',title:'地址',width:100,align:'left',sortable:true}
 		      ]],
 		 hideColumn:['state'],
 		 pagination:true,
 		 rownumbers:true,
 		 toolbar:[{
 			}]
 	});
 	
	$("#btnTest").click(function() {
		var url = appPath+"/itbImg/getImageList.action";  
        $.ajax({  
                    url : url,  
                    cache : false,  
                    data : {"user_id": $("#username").val()},
                    type : "POST",  
                    datatype : "json",  
                    success : function(data) { 
                    	//var tmp = "";
                    	//$.each(data, function(index, info){
                        //   tmp += info.tmpl_id+" ";
                        //});
                       //alert(tmp);
                       
                    	
                    	$("#testGrid").datagrid('loadData', data);
                       
                    }  
                });  
        

	});

	$("#backButton").click(function() {
		document.forms[0].action = appPath+"/webgoods/homePageInit.action";
		document.forms[0].submit();
	});
	$("#loginbutton").click(function() {
		document.forms[0].action = appPath+"/webcom/UserLogin.action";
		document.forms[0].submit();
	});
	$("#registerButton").click(function() {
		document.forms[0].action = appPath+"/webcom/doInit.action";
		document.forms[0].submit();
	});
	});
	
/* 	function refresh()
	{
		document.getElementById("imgCode").src='${ctx}/system/login_keyword.do?a='+Math.random()+100;
	}
	
	function doLogin(e)
	{
		var keynum;
        if(window.event){//IE
			keynum = e.keyCode;
		}else if(e.which){// Netscape/Firefox/Opera
			keynum = e.which;
		}
		if(keynum == 13){
			login();	
		}
	}
	
	function login()
	{		
		if(!$('#loginDto').form('validate')){
			return ;
		}
		$("#loadInfo").html("登录中,请稍候...");
		$('#loginBtn').linkbutton("disable");    

		var loginDto = $('#loginDto');  
        var userinfo = loginDto.serialize();    
        $.ajax({
			type : "POST",
			url : "${ctx}/system/login_checkAuth.do",
			data : userinfo,
			success : function(msg){
				$("#loginRslt").css("display","none");
				$("#loginRslt").html("");
				$('#loginBtn').linkbutton("enable");
				
				if (msg=='OK'){
					var url = $("#requestURI").attr("value");
					if(url != null && url !='null' && url != ''){
						document.location.href =url;
					}else{
						document.location.href="${ctx}/jsp/index.jsp";	
					}
					
				}else{
					$("#loginRslt").css("display","block");
					$("#loginRslt").html(msg);
					refresh();
				}
					
			}
		});	
	} 
	
	
    	function redirect(){
    		var url = "${ctx}/jsp/index.jsp";
    		var args= "fullscreen=yes,z-look=yes,location=no,top=0,left=0,width="+screen.width+",height="+screen.height;
    		window.open(url,"",args);
    		var sAgent = navigator.userAgent.toLowerCase();
    		var isIE = (sAgent.indexOf("msie")!=-1);   
    		if(isIE){
    			window.opener=null;
        		window.open("","_self");    
        		window.close();	
    		}else{
    			window.location.reload(); 
    		}
    		
    	}	 */
</script>

</body>
</html>